
function change() {
	var pic = document.getElementById("preview"),
	    file = document.getElementById("file");

	var ext=file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

     // gif
     if(ext!='png'&&ext!='jpg'&&ext!='jpeg'){
         alert("请选择png或jpg或jpeg格式的图片"); 
         pic.src="";
		 return;
     }
     html5Reader(file);
}

 function html5Reader(file){
	 document.getElementById('wyinitImg').style.display='none';
	 document.getElementById('preview').style.display='block';
	 var isIE = navigator.userAgent.match(/MSIE/)!= null,
	 isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

 if(isIE) {
	file.select();
	var reallocalpath = document.selection.createRange().text;

	// IE6img
     if (isIE6) {
		pic.src = reallocalpath;
	 }else {
		// 
         pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + reallocalpath + "\")";
         // 
         pic.src = '';
	 }
 }else {
	 var file = file.files[0];
     var reader = new FileReader();
     reader.readAsDataURL(file);
     reader.onload = function(e){
         var pic = document.getElementById("preview");
         pic.src=this.result;
     };
 }
 }
 

 